/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.univali.programacao.carraid;

import java.awt.Graphics2D;
import javax.swing.ImageIcon;

/**
 *
 * @author Murilo
 */
public class Pista extends GameObject {

    public Pista() {
        ImageIcon imagem = new ImageIcon(getClass().getResource("/imagem/pista_sprite.jpg"));
        Sprite sprite = new Sprite(imagem.getImage(), 32, 36, 300, 600);
        setSprite(sprite);
    }

    
    @Override
    public void draw(Graphics2D g) {
        int xDest = (int) getX();
        int yDest = (int) getY();

        int right = xDest + getSprite().getLarguraDosQuadros();
        int bottom = yDest + getSprite().getAlturaDosQuadros();

        int xSource = getSprite().getQuadroAtual() * getSprite().getLarguraDosQuadros();
        int ySource = 0;

        int rightSource = xSource + getSprite().getLarguraDosQuadros();
        int bottomSource = ySource + getSprite().getAlturaDosQuadros();

        g.drawImage(getSprite().getImagem(),
                xDest, yDest, right, bottom, // Coordenadas de Destino
                xSource, ySource, rightSource, bottomSource, // Coordenadas de Origem
                null);
    }
    
}
